<%--
  Created by IntelliJ IDEA.
  User: zhangbo
  Date: 2021/11/7
  Time: 18:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>$Title$</title>
    <script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.js"></script>
    <script type="text/javascript">

        function on() {
            $.post({
                url: "${pageContext.request.contextPath}/t2",
                data: {
                    "name": $("#userName").val()
                },
                success: function (data) {
                    alert(data);
                },
                error: function () {
                    alert("错误");
                }
            })
        }


    </script>
</head>
<body>
<%--  失去焦点之后发送请求--%>
用户名：<input type="text" id="userName" onblur="on()">

</body>
</html>
